<?php
require_once('phpmailer/class.phpmailer.php');

class SendMail extends PageBase{
	var $email;
	var $userInfo;
	public function __construct($tpl,$email){
		parent::__construct($tpl);
		$this->email = $email;
	}
	function Ini(){
		$this->userInfo = $this->db->fetchOne("SELECT s.*,a.active_code,a.mail_open FROM biz_seller s,biz_seller_active a WHERE a.seller_id=s.seller_id AND seller_email_address={0}",$this->email);
		$this->assign('seller_id',$this->userInfo['seller_id']);
		$this->assign('active_code',$this->userInfo['active_code']);
	}
	function send(){
		global $EmailConfig;
		$mail = new PHPMailer();
		$mail->IsSMTP();                                   // send via SMTP
		$mail->Host     = $EmailConfig['SmtpServer']; // SMTP servers
		$mail->SMTPAuth = true;     // turn on SMTP authentication
		$mail->Username = $EmailConfig['user'];  // SMTP username
		$mail->Password = $EmailConfig['pwd']; // SMTP password
		
		$mail->From     = $EmailConfig['EmailAccount'];
		$mail->FromName = $EmailConfig['NickName'];
		$mail->AddAddress($this->email,$this->userInfo['seller_name']); 
		//$mail->AddAddress("ellen@site.com");               // optional name
		$mail->AddReplyTo($EmailConfig['EmailAccount'],$EmailConfig['NickName']);
		
		$mail->WordWrap = 50;                              // set word wrap
		//$mail->AddAttachment("/var/tmp/file.tar.gz");      // attachment
		//$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); 
		$mail->IsHTML(true);                               // send as HTML
		
		$mail->Subject  =  "=?UTF-8?B?" . base64_encode("酷店用户帐号激活") . "?=";
		$mail->Body     =  $this->fetch();
		
		return $mail->Send();
	}
}
?>